<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{$websiteData['titles']}}</title>
    <meta name="description" content="{{$websiteData['description']}}" />
    <meta name="keywords" content="{{$websiteData['keywords']}}" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" type="text/css" href="/static/home/sPage/jquery.sPage.css">
    <style>
        /* 全局样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        :root {
            --primary-color: #2c3e50;
            --secondary-color: #3498db;
            --accent-color: #e74c3c;
            --light-color: #ecf0f1;
            --dark-color: #2c3e50;
            --text-color: #333;
            --gray-color: #7f8c8d;
            --background-color: #f9f9f9;
        }

        body {
            background-color: var(--background-color);
            color: var(--text-color);
            line-height: 1.6;
        }

        a {
            text-decoration: none;
            color: var(--secondary-color);
            transition: color 0.3s;
        }

        a:hover {
            color: var(--accent-color);
        }

        .container {
            width: 90%;
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 15px;
        }

        .btn {
            display: inline-block;
            padding: 10px 20px;
            background-color: var(--secondary-color);
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s;
        }

        .btn:hover {
            background-color: var(--accent-color);
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        /* 头部样式 */
        header {
            background-color: var(--primary-color);
            color: white;
            padding: 20px 0;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .header-content {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            font-size: 1.8rem;
            font-weight: bold;
        }

        .logo span {
            color: var(--secondary-color);
        }

        nav ul {
            display: flex;
            list-style: none;
        }

        nav ul li {
            margin-left: 25px;
        }

        nav ul li a {
            color: white;
            font-weight: 500;
            padding: 5px 0;
            position: relative;
        }

        nav ul li a::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 0;
            height: 2px;
            background-color: var(--secondary-color);
            transition: width 0.3s;
        }

        nav ul li a:hover::after,
        nav ul li a.active::after {
            width: 100%;
        }

        nav ul li a.active {
            color: var(--secondary-color);
        }

        .search-bar {
            display: flex;
        }

        .search-bar input {
            padding: 8px 15px;
            border: none;
            border-radius: 4px 0 0 4px;
            outline: none;
        }

        .search-bar button {
            background-color: var(--secondary-color);
            color: white;
            border: none;
            padding: 8px 15px;
            border-radius: 0 4px 4px 0;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .search-bar button:hover {
            background-color: #2980b9;
        }

        .mobile-menu {
            display: none;
            font-size: 1.5rem;
            cursor: pointer;
        }

        /* 面包屑导航 */
        .breadcrumb {
            background-color: white;
            padding: 15px 0;
            margin: 30px 0;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        }

        .breadcrumb ul {
            display: flex;
            list-style: none;
        }

        .breadcrumb ul li {
            margin-right: 10px;
            font-size: 0.9rem;
        }

        .breadcrumb ul li:not(:last-child)::after {
            content: ">";
            margin-left: 10px;
            color: var(--gray-color);
        }

        /* 页面标题区域 */
        .page-header {
            margin-bottom: 30px;
        }

        .page-title {
            font-size: 2.2rem;
            margin-bottom: 10px;
            color: var(--dark-color);
        }

        .page-subtitle {
            color: var(--gray-color);
            font-size: 1.1rem;
        }

        /* 主要内容区域 */
        .main-content {
            display: flex;
            margin: 30px 0;
            gap: 30px;
        }

        .content {
            flex: 3;
        }

        .sidebar {
            flex: 1;
        }

        /* 筛选工具栏 */
        .filter-bar {
            background: white;
            border-radius: 8px;
            padding: 20px;
            margin-bottom: 30px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 15px;
        }

        .filter-options {
            display: flex;
            gap: 15px;
        }

        .filter-select {
            padding: 8px 15px;
            border: 1px solid #ddd;
            border-radius: 4px;
            background-color: white;
            outline: none;
            cursor: pointer;
        }

        .view-options {
            display: flex;
            gap: 10px;
        }

        .view-btn {
            padding: 8px 12px;
            background-color: var(--light-color);
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .view-btn.active {
            background-color: var(--secondary-color);
            color: white;
        }

        .view-btn:hover:not(.active) {
            background-color: #dde4e6;
        }

        /* 文章列表样式 */
        .section-title {
            font-size: 1.8rem;
            margin-bottom: 20px;
            color: var(--dark-color);
            position: relative;
            padding-bottom: 10px;
        }

        .section-title::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 60px;
            height: 3px;
            background-color: var(--secondary-color);
        }

        .article-list {
            display: flex;
            flex-direction: column;
            gap: 25px;
            margin-bottom: 50px;
        }

        .article-card {
            background: white;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            transition: transform 0.3s, box-shadow 0.3s;
            display: flex;
        }

        .article-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
        }

        .article-image {
            width: 250px;
            overflow: hidden;
            flex-shrink: 0;
        }

        .article-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.5s;
        }

        .article-card:hover .article-image img {
            transform: scale(1.05);
        }

        .article-content {
            padding: 25px;
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .article-category {
            display: inline-block;
            background-color: var(--secondary-color);
            color: white;
            padding: 4px 10px;
            border-radius: 4px;
            font-size: 0.8rem;
            margin-bottom: 10px;
        }

        .article-meta {
            display: flex;
            color: var(--gray-color);
            font-size: 0.9rem;
            margin-bottom: 10px;
        }

        .article-meta span {
            margin-right: 15px;
        }

        .article-meta i {
            margin-right: 5px;
        }

        .article-title {
            font-size: 1.4rem;
            margin-bottom: 10px;
        }

        .article-title a {
            color: var(--dark-color);
        }

        .article-title a:hover {
            color: var(--secondary-color);
        }

        .article-excerpt {
            color: var(--gray-color);
            margin-bottom: 15px;
            line-height: 1.7;
        }

        .read-more {
            display: inline-block;
            background-color: var(--secondary-color);
            color: white;
            padding: 8px 15px;
            border-radius: 4px;
            font-weight: 500;
            transition: background-color 0.3s;
            align-self: flex-start;
        }

        .read-more:hover {
            background-color: var(--accent-color);
            color: white;
        }

        /* 网格视图样式 */
        .article-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 30px;
            margin-bottom: 50px;
        }

        .article-grid .article-card {
            flex-direction: column;
        }

        .article-grid .article-image {
            width: 100%;
            height: 200px;
        }

        /* 分页样式 */
        .pagination {
            display: flex;
            justify-content: center;
            margin: 40px 0;
        }

        .pagination a {
            display: inline-block;
            padding: 10px 15px;
            margin: 0 5px;
            background-color: white;
            color: var(--text-color);
            border-radius: 4px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
            transition: all 0.3s;
        }

        .pagination a:hover,
        .pagination a.active {
            background-color: var(--secondary-color);
            color: white;
        }

        /* 侧边栏样式 */
        .sidebar-widget {
            background: white;
            border-radius: 8px;
            padding: 20px;
            margin-bottom: 30px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        }

        .widget-title {
            font-size: 1.2rem;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 2px solid var(--light-color);
            color: var(--dark-color);
        }

        .categories-list {
            list-style: none;
        }

        .categories-list li {
            margin-bottom: 10px;
            padding-bottom: 10px;
            border-bottom: 1px solid var(--light-color);
        }

        .categories-list li:last-child {
            margin-bottom: 0;
            padding-bottom: 0;
            border-bottom: none;
        }

        .categories-list li a {
            display: flex;
            justify-content: space-between;
            color: var(--text-color);
        }

        .categories-list li a:hover {
            color: var(--secondary-color);
        }

        .tag-cloud {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }

        .tag {
            background-color: var(--light-color);
            padding: 5px 10px;
            border-radius: 20px;
            font-size: 0.9rem;
            transition: background-color 0.3s;
        }

        .tag:hover {
            background-color: var(--secondary-color);
            color: white;
        }

        .popular-posts .popular-post {
            margin-bottom: 15px;
            padding-bottom: 15px;
            border-bottom: 1px solid var(--light-color);
        }

        .popular-posts .popular-post:last-child {
            margin-bottom: 0;
            padding-bottom: 0;
            border-bottom: none;
        }

        .popular-posts .popular-post h4 {
            margin-bottom: 5px;
        }

        .popular-posts .popular-post h4 a {
            color: var(--text-color);
        }

        .popular-posts .popular-post h4 a:hover {
            color: var(--secondary-color);
        }

        .post-meta {
            font-size: 0.85rem;
            color: var(--gray-color);
        }

        /* 通讯订阅样式 */
        .newsletter {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            color: white;
            padding: 40px;
            border-radius: 8px;
            text-align: center;
            margin-bottom: 50px;
        }

        .newsletter h2 {
            margin-bottom: 15px;
        }

        .newsletter p {
            margin-bottom: 20px;
            opacity: 0.9;
        }

        .newsletter-form {
            display: flex;
            max-width: 500px;
            margin: 0 auto;
        }

        .newsletter-form input {
            flex: 1;
            padding: 12px 15px;
            border: none;
            border-radius: 4px 0 0 4px;
            outline: none;
        }

        .newsletter-form button {
            background-color: var(--accent-color);
            color: white;
            border: none;
            padding: 12px 20px;
            border-radius: 0 4px 4px 0;
            cursor: pointer;
            font-weight: 500;
            transition: background-color 0.3s;
        }

        .newsletter-form button:hover {
            background-color: #d62c4c;
        }

        /* 页脚样式 */
        footer {
            background-color: var(--dark-color);
            color: white;
            padding: 50px 0 20px;
        }

        .footer-content {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            margin-bottom: 30px;
        }

        .footer-column {
            flex: 1;
            min-width: 200px;
            margin-bottom: 30px;
        }

        .footer-column h3 {
            font-size: 1.2rem;
            margin-bottom: 20px;
            color: var(--light-color);
        }

        .footer-links {
            list-style: none;
        }

        .footer-links li {
            margin-bottom: 10px;
        }

        .footer-links a {
            color: #bdc3c7;
        }

        .footer-links a:hover {
            color: white;
        }

        .social-links {
            display: flex;
            gap: 15px;
            margin-top: 20px;
        }

        .social-links a {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 40px;
            height: 40px;
            background-color: rgba(255, 255, 255, 0.1);
            border-radius: 50%;
            color: white;
            transition: background-color 0.3s;
        }

        .social-links a:hover {
            background-color: var(--secondary-color);
        }

        .copyright {
            text-align: center;
            padding-top: 20px;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            color: #bdc3c7;
            font-size: 0.9rem;
        }

        /* 响应式设计 */
        @media (max-width: 992px) {
            .main-content {
                flex-direction: column;
            }

            .header-content {
                flex-direction: column;
                align-items: flex-start;
            }

            nav {
                margin: 15px 0;
                width: 100%;
            }

            nav ul {
                justify-content: space-between;
                width: 100%;
            }

            nav ul li {
                margin: 0;
            }

            .search-bar {
                width: 100%;
                margin-top: 15px;
            }

            .search-bar input {
                flex: 1;
            }

            .article-card {
                flex-direction: column;
            }

            .article-image {
                width: 100%;
                height: 200px;
            }
        }

        @media (max-width: 768px) {
            .page-title {
                font-size: 1.8rem;
            }

            .article-grid {
                grid-template-columns: 1fr;
            }

            nav ul {
                flex-direction: column;
                display: none;
            }

            nav ul.show {
                display: flex;
            }

            nav ul li {
                margin: 5px 0;
            }

            .mobile-menu {
                display: block;
                position: absolute;
                top: 20px;
                right: 15px;
            }

            .filter-bar {
                flex-direction: column;
                align-items: flex-start;
            }

            .filter-options {
                width: 100%;
                justify-content: space-between;
            }

            .view-options {
                align-self: flex-end;
            }

            .newsletter-form {
                flex-direction: column;
            }

            .newsletter-form input {
                border-radius: 4px;
                margin-bottom: 10px;
            }

            .newsletter-form button {
                border-radius: 4px;
            }
        }

        @media (max-width: 576px) {
            .page-title {
                font-size: 1.6rem;
            }

            .section-title {
                font-size: 1.5rem;
            }

            .footer-column {
                flex: 100%;
            }
        }
    </style>
</head>
<body>
<!-- 头部区域 -->
@include("home.index2.head")

<!-- 面包屑导航 -->
<div class="container">
    <div class="breadcrumb">
        <ul>
            <li><a href="{{route('home.index')}}">首页</a></li>
            <li>{{$topicInfo['titles']}}</li>
        </ul>
    </div>
</div>

<!-- 主要内容区域 -->
<div class="container">
    <div class="main-content">
        <!-- 文章内容 -->
        <div class="content">
            <!-- 筛选工具栏 -->
            <!-- 文章列表 - 列表视图 -->
            <div class="article-list" id="content">
            </div>
            <div id="myPage" class="demo"></div>
        </div>

        <!-- 侧边栏 -->
        <div class="sidebar">
            <div class="sidebar-widget">
                <h3 class="widget-title">文章分类</h3>
                <ul class="categories-list">
                    @foreach($websiteColumnArr as $val)
                        <li><a href="{{route('home.article.list')}}?topicId={{$val['id']}}&indexActive={{$val['indexActive']}}">{{$val['titles']}} <span>({{$val['article_count']}})</span></a></li>
                    @endforeach
                </ul>
            </div>

            <div class="sidebar-widget">
                <h3 class="widget-title">热门文章</h3>
                <div class="popular-posts">
                    @foreach($lastArticleData as $hotVal)
                        <div class="popular-post">
                            <h4><a href="{{route('home.article.info')}}?id={{$hotVal['id']}}&indexActive={{$indexActive}}">{{$hotVal['title']}}</a></h4>
                            <div class="post-meta">{{$hotVal['publish_time']}}.阅读 {{$hotVal['read_count']}}</div>
                        </div>
                    @endforeach
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 页脚 -->
@include("home.index2.footer")
<script src="/static/home/js/jquery.js"></script>
<script src="/static/home/sPage/jquery.sPage.min.js"></script>
<script>

    $(function () {
        ajaxPage(1);
        function ajaxPage(page) {
            var p = page || 1;
            var article_title = $("#article_title").val();
            $.ajax({
                type: "GET",
                url: "{{route('home.article.listData')}}",
                data: {
                    page: p,
                    pageSize: 10,
                    article_title:article_title,
                    topicId:{{$topicId}},
                    indexActive:{{$indexActive}}
                },
                dataType: "json",
                success: function(data) {
                    //数据处理
                    var _html="";
                    var articleData = data.data;
                    $.each(articleData,function (index,val) {
                        _html+=
                            '                   <div class="article-card">' +
                            '                        <div class="article-image">' +
                            '                            <img src="'+val.thumb+'" alt="">' +
                            '                        </div>' +
                            '                        <div class="article-content">' +
                            '                            <span class="article-category">'+val.topicTitle+'</span>' +
                            '                            <div class="article-meta">' +
                            '                                <span><i class="far fa-calendar"></i> '+val.publish_time+'</span>' +
                            '                                <span><i class="far fa-eye"></i> '+val.read_count+'</span>' +
                            '                            </div>' +
                            '                            <h3 class="article-title"><a href="'+val.url+'">'+val.title+'</a></h3>' +
                            '                            <p class="article-excerpt">'+val.brief+'</p>' +
                            '                            <a href="'+val.url+'" class="read-more">阅读全文</a>' +
                            '                        </div>' +
                            '                    </div>';
                    });
                    $("#content").html(_html);
                    // ...
                    // 调用分页插件
                    $("#myPage").sPage({
                        page: p, //当前页码
                        pageSize: 10, //每页显示多少条数据，默认10条
                        total: data.total, //数据总条数,后台返回
                        totalTxt:"共{total}条",//数据总条数文字描述，{total}为占位符，默认"共{total}条"
                        showTotal:true,//是否显示总条数，默认关闭：false
                        showSkip:true,//是否显示跳页，默认关闭：false
                        showPN:true,//是否显示上下翻页，默认开启：true
                        prevPage:"上一页",//上翻页文字描述，默认“上一页”
                        nextPage:"下一页",//下翻页文字描述，默认“下一页”
                        backFun: function(page) { //点击分页按钮回调函数，返回当前页码
                            ajaxPage(page);
                        }
                    });
                },
                error: function(e) {
                    console.log(e);
                }
            });
        };
        //点击搜素
        $("#searchData").click(function(){
            ajaxPage(1);
        });
    });



    // 移动端菜单切换
    document.getElementById('mobile-menu').addEventListener('click', function() {
        document.getElementById('nav-menu').classList.toggle('show');
    });

    // 文章卡片点击效果
    document.querySelectorAll('.article-card').forEach(card => {
        card.addEventListener('click', function(e) {
            if (e.target.tagName !== 'A' && !e.target.classList.contains('read-more')) {
                const link = this.querySelector('.article-title a');
                if (link) {
                    window.location.href = link.href;
                }
            }
        });
    });

    // 搜索功能
    const searchButton = document.querySelector('.search-bar button');
    const searchInput = document.querySelector('.search-bar input');

    searchButton.addEventListener('click', function() {
        performSearch();
    });

    searchInput.addEventListener('keypress', function(e) {
        if (e.key === 'Enter') {
            performSearch();
        }
    });

    function performSearch() {
        const keywords = searchInput.value.trim();
        if (keywords) {
            window.location.href = "{{route('home.article.list')}}?topicId={{$topicId}}&indexActive={{$indexActive}}&keywords="+keywords;
        }
    }

</script>
</body>
</html>
